﻿ <%--
  *  File:    ZylOtherCustomerCollateEdit.jsp
  *  @Author: KevinFan
  *  Date:    2011/11/29
  *
  *  Copyright (C) 2000 - 2012 Oval Technologies, Inc.
  *  All rights reserved.
  *
  *  This software is the confidential and proprietary information of Oval
  *  Technologies, Inc. ("Confidential Information").  You shall not
  *  disclose such Confidential Information and shall use it only in
  *  accordance with the terms of the license agreement you entered into
  *  with Oval.
 --%>

<%@ page contentType = "text/html;charset=UTF-8" %>

 <%
   //init param
   Category cat = Category.getInstance("jsp.ZylCustomerCollateEdit");
   String strTableName = "v_customercollateedit";
   String strModuleName = "CM";
   String privilegeCode = "A0701";
     String contextPath = request.getContextPath();
 %>
        <%@ include file="/inc/CommonHeader.inc" %>
        <%@ include file="/inc/OvalLocationDefault.inc" %>
		<%@ include file="/inc/Print.inc"%>
		<%@ include file="/rpt/ReportURL.inc" %>
 <%
   //get curuser info
   HashMap CurUserInfo = (HashMap)session.getAttribute("userinfo");
   String strCurOrgName = (String)CurUserInfo.get("orgname");
   Integer nCurOrgId = (Integer)CurUserInfo.get("orgid");
   Integer nCurUserId = (Integer)CurUserInfo.get("userid");
   if(nCurOrgId == null)
   {
     nCurOrgId = new Integer(-1234567);
   }
 %>

 <html>
 <head>
 <title>ZylOtherCustomerCollateEdit</title>
 <PageFlow:CheckPageFlow pageName="p_othercustomercollate"/>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 <%@ include file="/inc/CatchError.inc" %>
 <script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>
 <script language="JavaScript" src="<%=contextPath %>/js/SummaryDivision.js"></script>
 <link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
 <script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
 <script language="JavaScript" src="<%=contextPath %>/js/Calendar.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/opal2/mootools.js"></script>
 <%@ include file="/inc/SummaryDivision.inc" %>
 <%
   Vector totalsummary = (Vector)pageContext.getAttribute("totalsummary");
   if(totalsummary == null)
   {
     totalsummary = new Vector();
   }
   
	String orgoptionvalue = (String)pageContext.getAttribute("orgoption");
	if(orgoptionvalue == null)orgoptionvalue = "1";
 %>
 <script>
 var popwindow;
 function page_summary(actionvalue,orderbyname)
 {
     if(isEmpty(cform.keyname.value) && false)
     {
         alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_CustomerKey"))%>");
         return;
     }

   var editform = summaryPrepare(cform,actionvalue,orderbyname);
   editform.action = "ZylOtherCustomerCollateEdit.jsp?<%= OvalTools.randomURL() %>&flag=y";
   editform.target = "_self";
   isRunning = true;
   editform.submit();
 }

 var type;

 function page_selectProvince(obj)
 {
   type=obj;
   if(popwindow!=null)
    popwindow.close();
   popwindow = window.open('<%=contextPath %>/masterdata/ogm/RegionSelect.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode %>&countrycode=CN','newwindow', 'height=250, width=500,top=100,left=100,toolbar=n0, menubar=no, scrollbars=no, resizable=no, location=no, status=no');
 }

 function page_setRegion(code,name)
 {
	 var regioncode;
     var regionname;
     var citycode;
     var cityname;
	 var countycode;
	 var countyname;
     if(type=='customer'){
		 regioncode=eval('document.cform.regioncode');
         regionname=eval('document.cform.regionname');
         citycode=eval('document.cform.citycode');
         cityname=eval('document.cform.cityname');
     }else if(type=='newcustomer'){
		 regioncode=eval('document.cform.newregioncode');
         regionname=eval('document.cform.newregionname');
         citycode=eval('document.cform.newcitycode');
         cityname=eval('document.cform.newcityname');
		 countycode = eval('document.cform.newcountycode');
		 countyname = eval('document.cform.newcountyname');
     } else{
		 regioncode=eval('document.cform.sregioncode');
         regionname=eval('document.cform.sregionname');
         citycode=eval('document.cform.scitycode');
         cityname=eval('document.cform.scityname');
     }

     if(code != regioncode.value && type=='newcustomer'){
         citycode.value='';
         cityname.value='';
		 countycode.value='';
         countyname.value='';
     }else{
		 citycode.value='';
         cityname.value='';
	 }
   regioncode.value = code;
   regionname.value = name;
   if(type!='newcustomer'){
	cform.newsregioncode.value = code;
	cform.newsregionname.value = name;
   }
   if (popwindow != null)
     popwindow.close();
 }

 function page_selectCity(obj,flag,grade)
 {
	 var proidstring = document.cform.proid.value;
     var sregioncode = document.cform.sregioncode.value;
	 var sregionname = document.cform.sregionname.value;
     type=obj;
      var regioncode;
     if(type=='customer')
     {
         regioncode=eval('document.cform.regioncode');
     }
     else
     {
         regioncode=eval('document.cform.sregioncode');
     }
   if(isEmpty(regioncode.value))
   {
     alert("<%= message.getMessageDesc("MUST_SELECT_FIRST",label.getLabelName("L_Province"))%>");
     return;
   }
   if(popwindow!=null)
     popwindow.close();
   popwindow = window.open('<%=contextPath %>/masterdata/ogm/CitySelect.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode %>&countrycode=CN' + '&regioncode=' + regioncode.value +'&proidstring='+proidstring + '&flag=' + flag+'&grade='+grade,'newwindow', 'height=250, width=400,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no');
 }

 function page_setCity(code,name,id,flag)
 {
     if(type=='newcustomer'){
		page_setCity1(code,name,id,flag);
		return;
	 }
	 var citycode;
     var cityname;
     if(type=='customer'){
         citycode=eval('document.cform.citycode');
         cityname=eval('document.cform.cityname');
     }else{
         citycode=eval('document.cform.scitycode');
         cityname=eval('document.cform.scityname');
     }
   citycode.value = code;
   cityname.value = name;
   if(type!='newcustomer'){
	cform.newscitycode.value = code;
	cform.newscityname.value = name;
   }
   if (popwindow != null)
     popwindow.close();
 }
 function page_setCity1(code,name,id,flag)
{
	if(flag == "county"){
		document.cform.newcountycode.value = code;
		document.cform.newcountyname.value = name;
	}else {
		document.cform.newcitycode.value = code;
		document.cform.newcityname.value = name;
		document.cform.newcountycode.value = " ";
    	document.cform.newcountyname.value = " ";
	}
  if (popwindow != null)
    popwindow.close();
}

function page_selectCity1(obj,flag,grade)
{
  type=obj;
  var regioncode = document.cform.newregioncode.value;
  var parentcitycode = document.cform.newcitycode.value;
  if(flag=="city")parentcitycode='null';
  if(regioncode=="" || regioncode==-1)
  {
    alert("<%= message.getMessageDesc("MUST_SELECT_FIRST",label.getLabelName("L_Province"))%>");
    return;
    if(parentcitycode=="" || parentcitycode==-1)
  {
    alert("<%= message.getMessageDesc("MUST_SELECT_FIRST",label.getLabelName("L_City"))%>");
    return;
  }
  }
  
  if(popwindow!=null)
    popwindow.close();
  popwindow = window.open('<%=contextPath %>/masterdata/ogm/CitySelect.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode %>&countrycode=CN&regioncode=' + regioncode + '&flag=' + flag+'&grade='+grade+'&parentcitycode='+parentcitycode,'newwindow', 'height=250, width=400,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no');
}

 function page_changeRegion(obj)
 {
	var regioncode = cform.newsregioncode.value;
	page_cleanregionandcity();
	if(regioncode == "")return;
    var datahandler = new  DataHandler() ;
    datahandler.add_params("regioncode" , regioncode, 'String') ;
    datahandler.add_params("languagecode" , document.cform.languagecode.value, 'String') ;
    datahandler.getResult("regioncode" ,"document.cform.sregioncode");
    datahandler.getResult("regioncode" ,"document.cform.newsregioncode");
    datahandler.getResult("regionname" ,"document.cform.newsregionname");
    datahandler.getResult("regionname" ,"document.cform.sregionname");
    datahandler.add_job("j_getregionbycode");
    datahandler.runDataHandler();
 }

function page_checkRegion(){
	if(cform.sregioncode.value == ""){
		cform.newsregioncode.value = "";
	}
}
 
 function page_changeCity(obj)
 {
	var regioncode = cform.newsregioncode.value;
	var citycode = cform.newscitycode.value;
	if(isEmpty(regioncode))
	{
	  alert("<%= message.getMessageDesc("MUST_SELECT_FIRST",label.getLabelName("L_Province"))%>");
	  return;
	}
	page_cleancity();
	if(regioncode == "")return;
	var datahandler = new  DataHandler() ;
	datahandler.add_params("regioncode" , regioncode, 'String') ;
	datahandler.add_params("citycode" , citycode, 'String') ;
	datahandler.add_params("languagecode" , document.cform.languagecode.value, 'String') ;
	datahandler.getResult("citycode" ,"document.cform.scitycode");
	datahandler.getResult("citycode" ,"document.cform.newscitycode");
	datahandler.getResult("cityname" ,"document.cform.newscityname");
	datahandler.getResult("cityname" ,"document.cform.scityname");
	datahandler.add_job("j_getcitybycode");
	datahandler.runDataHandler();
 }
 
function page_cleanregionandcity(){
	cform.sregioncode.value = "";
	cform.newsregioncode.value = "";
	cform.sregionname.value = "";
	cform.newsregionname.value = "";
	cform.scitycode.value = "";
	cform.newscitycode.value = "";
	cform.scityname.value = "";
	cform.newscityname.value = "";
}

function page_cleancity(){
	cform.scitycode.value = "";
	cform.newscitycode.value = "";
	cform.scityname.value = "";
	cform.newscityname.value = "";
}

function page_download2(){
	var url;
	var searchStr="";
	var searchStrValue = "";
	var searchname = cform.searchnamealias.options[cform.searchnamealias.selectedIndex].value;
	var searchvalue =cform.searchvalue.value;
	if(searchvalue==""||searchvalue==null)searchStr=null;
	var searchnamevalue = searchname.substring(0,searchname.indexOf("^"));
	if(searchnamevalue == "dealername") seachStrValue="a.orgname";
	if(searchnamevalue == "dealercode") seachStrValue="a.orgcode";
	searchStr = "and "+seachStrValue+" like '"+searchvalue+"'";
	var inorgname =cform.keyname.value;
	var notinorgname = cform.keynameexc.value;
	var areacodeid = cform.regionid.options[cform.regionid.selectedIndex].value;
	if(areacodeid==""||areacodeid==null)
	{
		alert("请选择您所在的大区");
		return;
	}
	var regioncode = cform.newsregioncode.value;
	var citycode = cform.newscitycode.value;
	var checked = document.getElementsByName("clstflag");
	if(!checked[1].checked){
		alert("必须选中未对照上的客户列表");
		return;
	}
	url= "<%=reportURL%>"+"/servlet/ExcecuteReport/nonlockfailcustomercollate.sox?__folder=/ovalreport&<%= OvalTools.randomURL() %>&userid=<%=nCurUserId%>&areacodeid="+areacodeid; 
	if(!isEmpty(searchvalue)) url += "&searchnamevalue=" + escape(encodeURI(searchStr));
	if(!isEmpty(inorgname)) url += "&inorgname=" + escape(encodeURI(inorgname));
	if(!isEmpty(notinorgname)) url += "&notinorgname=" + escape(encodeURI(notinorgname));
	if(!isEmpty(areacodeid)) url += "&areacodeid=" + escape(encodeURI(areacodeid));
	if(!isEmpty(regioncode)) url += "&regioncode=" + escape(encodeURI(regioncode));
	var style = "height=600, width=900, top=50, left=120, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no";
	window.open (url, 'newwindow', style);
}
function page_upload(){
	this.location.href = "<%= contextPath%>/phap/masterdata/spm/UploadEXL.jsp?first=ZZ&second=ZB01&third=Z0608&<%= OvalTools.randomURL() %>";
}
 </script>
 </head>
 <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
 <iframe name="summaryfrm" scrolling="yes" frameborder="0" style="position:absolute; top:0px; left:0px; display:none;border:#909eff 1px solid;"></iframe>
 <iframe id="reloadHandler" name="reloadHandler" style="display:none"></iframe>
  <form name="cform" method="post" action="<%=contextPath %>/Dispatcher">
       <input type="hidden" name="pagename" value="p_othercustomercollate">
       <input type="hidden" name="actionname"/>
	   <input type="hidden" name="name" value="">
  	   <input type="hidden" name="type" value="">
  	   <input type="hidden" name="clstflagvalue" value="">
  	   <custom:hidden property="proid"/>
	   <custom:hidden property="cityid"/>
       <custom:hidden property="sregioncode"/>
       <custom:hidden property="sregionname"/>
       <custom:hidden property="scitycode"/>
       <custom:hidden property="scityname"/>
       <custom:hidden property="messagecode"/>
       <custom:hidden property="s1"/>
       <custom:hidden property="languagecode" scope="session"/>
	   <custom:hidden name="userinfo" property="userid" scope="session"/>
	   <custom:hidden property="orgids"/>
 <%--  page location   --%>
   <%@ include file="/inc/PageLocation.inc" %>

     <table width="100%" cellspacing="0" cellpadding="0" border="0" onkeydown="if(event.keyCode==13) page_summary('search');">

         <tr>
             <td width="80%">
                 <table  width="100%" cellspacing="0" cellpadding="0" border="0"  >
                       <tr>
                         <td  align="right" width="120">
                             <font color=black><%= label.getLabelName("L_CustomerKey") + label.getLabelName("L_Colon") %></font>
                         </td>
                         <td>
                             <custom:text property="keyname"  size="15"/>
                         </td>
						 <td align="right" width="100">
                             <%= label.getLabelName("L_KeyExclude") + label.getLabelName("L_Colon") %>
                         </td>
                         <td>
                             <custom:text property="keynameexc" size="15"/>
                         </td>
                         <td style="width:40px;" class="td_right">
							<font color=red><%=label.getLabelName("L_Businessarea") +  label.getLabelName("L_Colon") %></font>
						 </td>
						 <td style="width:160px;" class="td_left"><custom:select property="regionid" optionInnerTextKey="regionname" style="width:160px" optionsName="resultregion" optionValueKey="regionid" onchange="page_getpriviceoffice()" defaultValue="ALL" defaultValueCost=""/></td>
                         <%
                                String clstflag = (String)pageContext.getAttribute("clstflag");
                                if(clstflag==null){
                                    clstflag="N";
                                }
                         %>
                       </tr>
<%-----------------------第二行---------------------%>
                       <tr>
                       <td align="right" width="120"><%= label.getLabelName(" L_DealerProvince") + label.getLabelName("L_Colon") %>
                         </td>
                         <td>
                             <custom:text property="newsregioncode"  size="15" onchange="page_changeRegion('supplier')"/>
                             <a onclick="javascript:page_selectProvince('supplier');"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
                             <custom:text property="newsregionname" size="20" readonly="true"/>
                         </td>
                         <td align="right" width="100">
                             <%= label.getLabelName(" L_DealerCity") + label.getLabelName("L_Colon") %>
                          </td>
                         <td>
                             <custom:text property="newscitycode"   size="15" onchange="page_changeCity('supplier')"/>
                             <a onclick="javascript:page_selectCity('supplier','city',1);"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
                             <custom:text property="newscityname"   size="20" readonly="true" />
                         </td>
                       </tr>
                 </table>
                 <table>
						  <%@ include file="/inc/SummarySearch.inc" %>
                 </table>
              </td>
             <td width="20%">
             	<table>
					<tr>
						<tr>
						<td>
							<input name="clstflag" type="radio" class="normalradio" value="A" <%=clstflag.equalsIgnoreCase("A")?"checked":""%>>
							<%= label.getLabelName("L_AllCustomerList") %>
						</td>
						<td>&nbsp;</td>             	
					</tr>
					<tr>
						<td>
							<input name="clstflag" type="radio" class="normalradio" value="V" <%=clstflag.equalsIgnoreCase("V")?"checked":""%>  checked="true">
							<%= label.getLabelName("L_Auto_CustomerList") %>
						</td>
						<td>&nbsp;</td>
					</tr>
					<tr>
						<td>
							<input name="clstflag" type="radio" class="normalradio" value="S" <%=clstflag.equalsIgnoreCase("S")?"checked":""%>>
							<%= label.getLabelName("L_StandardCustoms") %>
						</td>
						<td>&nbsp;</td>
					</tr>
					</tr>
             	</table>
              </td>
           </tr>
                    
           <tr>
             <td colspan="2">
              <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
				 <tr class="deepblue-left">
                   <td class="title_center"><a href="javascript:page_summary('orderby','dealercode')"><%= label.getLabelName("L_DealerCode") %></a></td>
				   <td class="title_center"><a href="javascript:page_summary('orderby','dealername')"><%= label.getLabelName("L_DealerName") %></a></td>
                   <td class="title_center"><a href="javascript:page_summary('orderby','sregionname')">经销商所属省</a></td>
                   <td class="title_center"><a href="javascript:page_summary('orderby','scityname')">经销商所属市</a></td>
				   <td class="title_center"><a href="javascript:page_summary('orderby','origincustname')">原始客户名称</a></td>
                 </tr>
                 <%
                        String strClassType="";
                        int i = 0;
                 %>
                 <logic:iterate id="info" collection="<%= totalsummary %>" >
                 <%
                     if(i%2 == 1)
                         {
                             strClassType = "td-listrom";
                         }else{
                             strClassType = "none";
                         }
                     i++;
                 %>
                     <tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%= strClassType %>'" class="<%= strClassType %>">
                         <td>&nbsp;<custom:write name="info" property="dealercode"/></td>
						 <td><custom:write name="info" property="dealername"/></td>
                         <td>&nbsp;<custom:write name="info" property="sregionname"/></td>
                         <td>&nbsp;<custom:write name="info" property="scityname"/></td>
                         <td><custom:write name="info" property="origincustname"/></td>
                     </tr>
                  </logic:iterate>
                 <%@ include file="/inc/SummaryAction.inc" %>
               </table>
            </td>
       </tr>
       <tr>
         <td colspan="2">
           <table width="100%" border="0" cellspacing="0" cellpadding="0">
             <tr>
               <td class="summary_top" ></td>
             </tr>
             <tr>
                 <td class='title_center'>
					<custom:button label="L_Upload" styleClass="button1" style="width:80px;" onclick="page_upload()"/>
					<custom:button value="下载" styleClass="button1" style="width:80px;" onclick="page_download2()"/>
                 </td>
               </tr>
           </table>
         </td>
     </tr>
     <tr>
         <td>&nbsp;</td>
     </tr>
 </table>
 </form>
 </body>
 </html>


